import java.io.*;

public class Position
implements Serializable {

  public double x,y,z;

  private void writeObject(ObjectOutputStream out)
  throws IOException {
    out.writeDouble(x);
    out.writeDouble(y);
    out.writeDouble(z);
  }

  private void readObject(ObjectInputStream in)
  throws IOException, ClassNotFoundException {
    x = in.readDouble();
    y = in.readDouble();
    z = in.readDouble();
  }

  public Position(double a,double b,double c) {
    x = a; y = b; z = c;
  }

  public Position(double a,double b) {
    x = a; y = b; z = 0;
  }  

  public final int x() { return (int)x; }

  public final int y() { return (int)y; }

  public final static double dot(Position a,Position b) {
    return a.x*b.x+a.y*b.y+a.z*b.z;
  }

  public final double length() {
    return Math.sqrt(x*x+y*y+z*z);
  }

  public static final double distance(Position a,Position b) {
    double x = a.x-b.x;
    double y = a.y-b.y;
    double z = a.z-b.z;
    return Math.sqrt(x*x+y*y+z*z);
  }

  public final void normalize() {
    double len = length();
    x /= len;
    y /= len;
    z /= len;
  }

  public String toString() {
    String s = x+" "+y;
    return "(Position "+s+" )";
  }


}








